package net.ifilm.common;

import java.util.LinkedList;

/**
 * Created with IntelliJ IDEA.
 * User: Administrator
 * Date: 13-7-15
 * Time: 下午4:35
 * To change this template use File | Settings | File Templates.
 */
public class Queue<T> {

    private LinkedList<T> list = new LinkedList<T>();

    public synchronized void put(T t) {
        list.addLast(t);
        notifyAll();
    }

    public synchronized T get() {
        while (list.isEmpty()) {
            try {
                wait();
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

        return list.removeFirst();
    }

    public int size() {
        return list.size();
    }
}